import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

import static java.lang.Math.abs;

public class BinarySearchTree {

    public TreeNode Convert(TreeNode root) {
        if(root == null) return null;
        ArrayList<TreeNode> list = new ArrayList<>();
        inOrder(root,list);

        int size = list.size();
        for(int i = 1; i < size - 1;i++){
            TreeNode cur = list.get(i);
            cur.left = list.get(i - 1);
            cur.right = list.get(i + 1);
        }

        if(size > 1){
            list.get(0).right = list.get(1);
            list.get(size - 1).left = list.get(size - 2);
        }

        return list.get(0);
    }

    private void inOrder(TreeNode root,ArrayList<TreeNode> list){
        if(root == null) return;
        inOrder(root.left,list);
        list.add(root);
        inOrder(root.right,list);
    }


    static class TreeNode {
        public int key;
        public int val;
        public TreeNode left;
        public TreeNode right;

        TreeNode(int key,int val) {
            this.key = key;
            this.val = val;
        }
    }

    public TreeNode root;

    /**
     * 插入一个元素
     * @param key
     */
    public boolean insert(int key) {
        if(root == null){
            root.val = key;
            return true;
        }
        TreeNode cur = root;
        TreeNode parent = null;
        while(cur != null){
            if(cur.val > key){
                parent = cur;
                cur = cur.left;
            }else if(cur.val < key){
                parent = cur;
                cur = cur.right;
            }else {
                System.out.println("已有该元素");
            }
        }
        if(parent.val < key){
            parent.right.val = key;
        }
        if(parent.val > key){
            parent.left.val = key;
        }
        return true;
    }
    //查找key是否存在
    public TreeNode search(int key) {
        if(root == null) return null;
        TreeNode cur = root;
        while(cur != null){
            if(cur.val < key){
                cur = cur.right;
            } else if (cur.val > key) {
                cur = cur.left;
            }else{
                System.out.println("找到了");
                return cur;
            }
        }
        return null;
    }
    //删除key的值
    public boolean remove(int key) {
        if(root == null) return false;

        //首先找到Key
        TreeNode cur = root;
        TreeNode parent = null;
        while(cur != null){
            if(cur.val > key){
                parent = cur;
                cur = cur.left;
            }else if(cur.val < key){
                parent = cur;
                cur = cur.right;
            }else {
                delKey(cur,parent);
            }
        }
        return false;
    }

    private void delKey(TreeNode cur, TreeNode parent) {
        if(cur.left == null){
            if(cur == root){
                root = cur.right;
            }
            if(parent.left == cur){
                parent.left = cur.right;
            }
            if(parent.right == cur){
                parent.right = cur.right;
            }
        }else if(cur.right == null){
            if(cur == root){
                root = cur.left;
            }
            if(parent.left == cur){
                parent.left = cur.left;
            }
            if(parent.right == cur){
                parent.right = cur.left;
            }
        }else{
            //此时cur左右都不为空，则使用尾数交换法
            //要么使用左子树的最大值，要么使用右子树的最小值
            TreeNode curN = cur;
            while(curN != null){
                parent = curN;
                curN = curN.left;
            }
            //此时cur为空
            TreeNode tmp = parent.right;
            cur = tmp;
            parent.right = null;
        }
    }

    //只出现一次的数字
    public int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for(int i = 0;i < nums.length;i++){
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else{
                set.remove(nums[i]);
            }
        }
        for(int i = 0;i < nums.length;i++){
            if(set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }

    //宝石与石头
    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        int count = 0;
        for(int i = 0; i < jewels.length(); i++){
            if(!set.contains(jewels.charAt(i))){
                set.add(jewels.charAt(i));
            }
        }
        for(int i = 0; i < stones.length(); i++){
            if(set.contains(stones.charAt(i))){
                count++;
            }
        }
        return count;
    }

    //坏键盘打字
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str1 = in.nextLine();
            String str2 = in.nextLine();
            func(str1,str2);
        }
    }

    public static void func(String str1,String str2){
        str1 = str1.toUpperCase();
        str2 = str2.toUpperCase();

        Set<Character> set = new HashSet<>();
        for(char ch : str2.toCharArray()){
            set.add(ch);
        }

        Set<Character> set2 = new HashSet<>();
        for(int i = 0; i < str1.length();i++){
            if(!set.contains(str1.charAt(i)) &&
                    !set2.contains(str1.charAt(i))){
                set2.add(str1.charAt(i));
                System.out.print(str1.charAt(i));
            }
        }
    }

    //存在重复元素
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else{
                return true;
            }
        }
        return false;
    }

    //存在重复元素
    public boolean containsNearbyDuplicate(int[] nums, int k) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if(nums[i] == nums[j] && abs(i - j) <= k){
                    return true;
                }
            }
        }
        return false;
    }
}
